package com.base.api.controller.PtIntegral;


import com.base.result.ResponseResult;
import com.base.result.ResponseResultUtils;
import com.base.self.service.IPtintegralService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;

/**
 * <p>
 *  前端控制器
 * </p>
 */
@Api(tags = "拼团积分接口")
@RestController
@RequestMapping("/ptintegral")
public class PtintegralController {
    final
    IPtintegralService iPtintegralService;

    public PtintegralController(IPtintegralService iPtintegralService) {
        this.iPtintegralService = iPtintegralService;
    }

    @ApiOperation(value="查询用户拥有的积分")
    @PostMapping("/getPtIntegegralByUserId")
    public ResponseResult getPtIntegegralByUserId(@ApiParam("用户ID") @RequestParam String userId,@ApiParam("0正常 1冻结 不传查询全部") @RequestParam(required = false) Integer type){
        return ResponseResultUtils.getResponseResultDataS(iPtintegralService.getTotalMoneyByUserId(userId, type));
    }

    @ApiOperation(value="查询用户积分明细")
    @PostMapping("/getTotalMoneyResultDetailByUserId")
    public ResponseResult getTotalMoneyResultDetailByUserId(@ApiParam("用户ID") @RequestParam String userId,@ApiParam("0正常 1冻结 不传入查询全部") @RequestParam(required = false)  Integer type,@ApiParam("页码") @RequestParam Integer pageNo,@ApiParam("每页大小") @RequestParam Integer pageSize){
        return ResponseResultUtils.getResponseResultDataS(iPtintegralService.getTotalMoneyResultDetailByUserId(userId, type,pageNo,pageSize));
    }

    @ApiOperation(value="积分(信用金)兑换现金")
    @PostMapping("/castMoney")
    public ResponseResult castMoney(@ApiParam("用户id") String userId,@ApiParam("积分兑换数量") BigDecimal integralNum,@ApiParam("提现地址") String txPack){
        iPtintegralService.castMoney(userId,integralNum,txPack);
        return ResponseResultUtils.getResponseResultS("提现申请成功");
    }
    @ApiOperation(value="积分(信用金)兑换金豆(代理收益)")
    @PostMapping("/castSbdDetail")
    public ResponseResult castSbdDetail(@ApiParam("用户id") String userId,@ApiParam("积分兑换数量") BigDecimal integralNum){
        iPtintegralService.castSbdDetail(userId,integralNum);
        return ResponseResultUtils.getResponseResultS("兑换成功");
    }

}

